{extend name="public/base" /}
{block name="title"}站点管理员{/block} {block name="main"}
<style>
.td_left .layui-table-cell{
    padding-right: 0px !important;
    padding-left: 0px !important;
}


</style>
    <blockquote class="layui-elem-quote quoteBox">
        <form class="layui-form" action="" method="GET">
            <div class="layui-inline">
                <label class="layui-form-label">关键字</label>
                <div class="layui-inline">
                    <div class="layui-input-inline">
                        <input type="text" name="keyword" value="{$keyword}" class="layui-input searchVal" placeholder="请输入搜索的内容" />
                    </div>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">所属角色</label>
                <div class="layui-input-inline layui-col-md6">
                    <select name="roleid">
                        <option value="">请选择所属角色</option>
                        {volist name="rolelist" id="v"}
                        <option value="{$v['id']}" {$v[ 'id']==$roleid? 'selected': ''}>{$v['role']}</option>
                        {/volist}
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label layui-col-md4">状态</label>
                <div class="layui-input-inline layui-col-md4">
                    <select name="status">
                        <option value="" {$status==0? 'selected': ''}>请选择</option>
                        <option value="1" {$status==1? 'selected': ''}>正常</option>
                        <option value="2" {$status==2? 'selected': ''}>关闭</option>
                    </select>
                </div>
            </div>
            <button class="layui-btn search_btn" id="savebtn" lay-submit="">搜索</button>
            <div class="layui-inline">
                <a href="/site/admin/add" class="layui-btn layui-btn-normal addNews_btn">添加管理员</a>
            </div>
        </form>
    </blockquote>
    <form class="layui-form">
        <table cellspacing="0" cellpadding="0" border="0" style="width: 100%;" class="layui-table">
            <thead>
                <tr>
                    <th>ID</th>
                    <th>用户名</th>
                    <th>姓名</th>
                    <th>手机号</th>
                    <th>角色</th>
                    <th>登录次数</th>
                    <th style="width: 100px;" class="layui-table-cell">最后登录时间</th>
                    <th>IP</th>
                    <th style="width: 80px;">状态</th>
                    <th class="layui-table-fixed layui-table-fixed-r">操作</th>
                </tr>
            </thead>
            <tbody>
                {if condition="$data['msg']"}
                    <tr class="td_center"><td colspan="10">{$data['msg']}</td></tr>
                {/if}
                {volist name="data['list']" id="item"}
                <tr class="nodelist depth01">
                    <td class="td_left">
                        <div class="layui-table-cell ">{$item['adminid']}</div>
                    </td>
                    <td class="td_left">
                        <div class="layui-table-cell ">{$item['account']}</div>
                    </td>
                    <td class="td_left">
                        <div class="layui-table-cell ">{$item['name']}</div>
                    </td>
                    <td class="td_left">
                        <div class="layui-table-cell ">{$item['mobile']}</div>
                    </td>
                    <td class="td_left">
                        <div class="layui-table-cell ">{$item['role']}</div>
                    </td>
                    <td class="td_left">
                        <div class="layui-table-cell ">{$item['logins']}</div>
                    </td>
                    <td class="td_left">
                        <div class="layui-table-cell " style="width: 150px;">{$item['lastlogintime']?date("Y-m-d H:i:s",$item['lastlogintime']):''}</div>
                    </td>
                    <td class="td_left">
                        <div class="layui-table-cell ">{$item['ip']}</div>
                    </td>
                    <td>
                        <div class="layui-table-cell layui-inline" style="height:auto;">
                            <input lay-filter="status" type="checkbox" {$item[ 'status']==1? 'checked': ''} data-id="{$item['adminid']}" lay-skin="switch" lay-text="正常|关闭">
                        </div>
                    </td>
                    <td class="td_center">
                        <a href="/site/admin/edit/adminid/{$item['adminid']}" class="editNode layui-btn layui-btn-xs">编辑</a>
                    </td>
                </tr>
                {/volist}
            </tbody>
        </table>
    </form>
{$showpage|raw} 

{/block} {block name="script"}
<script>
    layui.use(['form'], function (form) {
        form.on('switch(status)', function (data) {
            var id = $(data.elem).data("id");
            var ischecked = data.elem.checked;
            $.post("/site/admin/editstatus",{adminid:id},function(ret){
                if(ret.code!=1){
                    layer.msg(ret.msg);
                    if(ischecked){
                        $(data.elem).prop("checked",false);
                        $(data.othis).removeClass("layui-form-onswitch").find("em").text("关闭");
                    }else{
                        $(data.elem).prop("checked",true);
                        $(data.othis).addClass("layui-form-onswitch").find("em").text("正常");
                    }
                }
            })
            return false;
        });
    });
</script> {/block}